package us.gaaoc.framework.dao;

import java.util.List;

import org.hibernate.Query;

import us.gaaoc.framework.model.OrganizationAddress;
import us.gaaoc.framework.model.Organizations;



/**
 * @author Sukhada
 *
 */
public class OrganizationAddressDAOHibernate extends
GenericHibernateDAO<OrganizationAddress, String, OrganizationAddressDAO> implements
OrganizationAddressDAO {
	
	public OrganizationAddress findOrgAddress(Organizations org, String streetAddress) {
		Query q = this.getSession().createQuery("from OrganizationAddress oa where oa.organization = ? and oa.streetFullText = ?");
		q.setEntity(0, org);
		q.setString(1, streetAddress);
		List result = q.list();
		if (result!=null && !result.isEmpty()){
			return (OrganizationAddress)result.get(0);
		}else
			return null;
	}

}
